package jumpingnotes.model.entity;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import net.jf.lucene.analysis.mmseg.MMSegAnalyzer;

import org.hibernate.search.annotations.Analyzer;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;

@Entity
@Table(name = "book_comment", catalog = "jumping_notes")
@Indexed
@Analyzer(impl = MMSegAnalyzer.class)
public class BookComment implements java.io.Serializable
{

	private Integer bookCommentId;
	private Member member;
	private Book book;
	private String body;
	private Date createTime;

	public BookComment()
	{
	}

	public BookComment(Member member, Book book)
	{
		this.member = member;
		this.book = book;
	}

	public BookComment(Member member, Book book, String body, Date createTime)
	{
		this.member = member;
		this.book = book;
		this.body = body;
		this.createTime = createTime;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "book_comment_id", unique = true, nullable = false)
	@DocumentId
	public Integer getBookCommentId()
	{
		return this.bookCommentId;
	}

	public void setBookCommentId(Integer bookCommentId)
	{
		this.bookCommentId = bookCommentId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "member_id", nullable = false)
	public Member getMember()
	{
		return this.member;
	}

	public void setMember(Member member)
	{
		this.member = member;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "book_id", nullable = false)
	public Book getBook()
	{
		return this.book;
	}

	public void setBook(Book book)
	{
		this.book = book;
	}

	@Column(name = "body", length = 65535)
	@Field(index = Index.TOKENIZED, store = Store.NO)
	public String getBody()
	{
		return this.body;
	}

	public void setBody(String body)
	{
		this.body = body;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time", length = 19)
	public Date getCreateTime()
	{
		return this.createTime;
	}

	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}

}
